package engine.render;

import engine.Displays;
import engine.render.buffer.TextBuffer;
import engine.render.buffer.TriBuffer;

public class RenderEngine 
{
    
    private float zNear;
    private float zFar;
    
    private TriBuffer dim3;
    public TriBuffer dim3() 
    {
        return dim3;
    }
    
    private TriBuffer dim2;
    public TriBuffer dim2() 
    {
        return dim2;
    }
    
    private TextBuffer textBuffer;
    public TextBuffer textBuffer() 
    {
        return textBuffer;
    }
    
    private GLManager glManager;
    public GLManager glManager() 
    {
        return glManager;
    }
    
    private GLEngine glEngine;
    
    private Frustum frustum;
    private FrusCuller frusCuller;
    
    public RenderEngine(Displays display) 
    {
        zNear = 0.2f;
        zFar = 72.0f;
        dim3 = new TriBuffer();
        dim2 = new TriBuffer();
        textBuffer = new TextBuffer();
        glManager = new GLManager();
        glEngine = new GLEngine(display, zNear, zFar);
        frustum = new Frustum(display, zNear, zFar);
        frusCuller = new FrusCuller();
    }
    
    public void priorToRender() 
    {
        frusCuller.cull(dim3, frustum, glManager);
        dim3.sort();
    }
    
    public void render() 
    {
        glEngine.render(
            dim2, dim3, 
            textBuffer, 
            glManager
        );
    }
    
}
